function rest=midptrule(array,dt)

arrend=max(size(array,1),size(array,2));
rest=(array(1)+array(arrend))/2*dt+sum(array(2:arrend-1))*dt;